package com.hspedu.shiyan1;

import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Comparator;

/**
 * @author DL5O
 * @version 1.0
 */

@SuppressWarnings("all")
public class zuoye1 {
    public static void main(String[] args) {
        int[] nums = {0,1, 2, 3, 4, 5};//五名选手的编号 A,B,C,D,E
        String[] scores = {"","第1名", "第2名", "第3名", "第4名", "第5名"};//名次
        for (int a = 1; a <= 5; a++) {
            for (int b = 1; b <= 5; b++) {
                for (int c = 1; c <= 5; c++) {
                    for (int d = 1; d <= 5; d++) {
                        for (int e = 1; e <= 5; e++) {

                            //约束条件1,编号1 2 3 4 5不为第一第二第三第四第五名
                            boolean tj1 = nums[a] != 1 && nums[b] != 2 && nums[c] != 3
                                    && nums[d] != 4 && nums[e] != 5;

                            //约束条件2，编号 1 2 3 4 5 没有相邻的
                            boolean tj2 = (nums[b] - nums[a]) != 1 &&
                                    (nums[c] - nums[b]) != 1 &&
                                    (nums[d] - nums[c] ) != 1 &&
                                    nums[e] - nums[d] != 1;

                            //约束条件3，猜中两个的排名
                            boolean tj3 = compare(nums[d], 1) +
                                    compare(nums[a], 2) +
                                    compare(nums[e], 3) +
                                    compare(c, 4) + compare(b, 5) == 2;

                            //约束条件4，两对相邻
                            boolean tj4 = compare(nums[a] - nums[d],1) +
                                    compare(nums[e] - nums[a],1) +
                                    compare(nums[c] - nums[e],1) +
                                    compare(nums[b] - nums[c],1) == 2;
                            //防止重复
                            boolean tj5 = nums[a] * nums[b] * nums[c] *
                                          nums[d] * nums[e] == 120;
                            boolean tj6 = nums[a] + nums[b] + nums[c] +
                                          nums[d] + nums[e] == 15;
                            if (tj1  && tj2  && tj3 && tj4 && tj5 && tj6) {
                                System.out.println("A:" + scores[a]);
                                System.out.println("B:" + scores[b]);
                                System.out.println("C:" + scores[c]);
                                System.out.println("D:" + scores[d]);
                                System.out.println("E:" + scores[e]);
                                System.out.println();
                            }
                        }
                    }
                }
            }
        }

    }

    //如果 num1 和 num2 相等 那么就返回1，如果不是就返回0
    public static int compare(int num1, int num2) {
        return num1 == num2 ? 1 : 0;
    }
}
